﻿/*
* Copyright (c) 2010-2012 Tesla Engine Group
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/


using Tesla.Math;

namespace Tesla.Graphics {
    /// <summary>
    /// Structure that represents a collection of values used for setting up a graphics presentation,
    /// e.g. window and swap chain.
    /// </summary>
    public struct PresentationParameters {
        /// <summary>
        /// Back buffer format.
        /// </summary>
        public SurfaceFormat BackBufferFormat;

        /// <summary>
        /// Depth-Stencil buffer format.
        /// </summary>
        public DepthFormat DepthStencilFormat;

        /// <summary>
        /// Width of the back buffer.
        /// </summary>
        public int BackBufferWidth;

        /// <summary>
        /// Height of the back buffer.
        /// </summary>
        public int BackBufferHeight;

        /// <summary>
        /// Number of samples to use in multi-sampling. Default is zero.
        /// </summary>
        public int MultiSampleCount;

        /// <summary>
        /// Number of qualtiy levels to use in multi-sampling. Default is zero.
        /// </summary>
        public int MultiSampleQuality;

        /// <summary>
        /// Is the presentation in full screen mode.
        /// </summary>
        public bool IsFullScreen;

        /// <summary>
        /// VSync enumeration.
        /// </summary>
        public PresentInterval PresentInterval;

        /// <summary>
        /// Backbuffer's render target usage.
        /// </summary>
        public RenderTargetUsage RenderTargetUsage;

        /// <summary>
        /// Display orientation of the presentation.
        /// </summary>
        public DisplayOrientation DisplayOrientation;

        /// <summary>
        /// Gets the bounds of the back buffer.
        /// </summary>
        public Rectangle Bounds {
            get {
                return new Rectangle(0, 0, BackBufferWidth, BackBufferHeight);
            }
        }

        /// <summary>
        /// Creates a new instance of <see cref="PresentationParameters"/>.
        /// </summary>
        /// <param name="format">The back buffer format..</param>
        /// <param name="depthFormat">The depth-stencil buffer format.</param>
        /// <param name="width">The back buffer width.</param>
        /// <param name="height">The back buffer height.</param>
        public PresentationParameters(SurfaceFormat format, DepthFormat depthFormat, int width, int height) {
            BackBufferFormat = format;
            DepthStencilFormat = depthFormat;
            BackBufferWidth = width;
            BackBufferHeight = height;
            MultiSampleCount = 0;
            MultiSampleQuality = 0;
            IsFullScreen = false;
            PresentInterval = PresentInterval.One;
            RenderTargetUsage = RenderTargetUsage.PlatformDefault;
            DisplayOrientation = DisplayOrientation.Default;
        }

        /// <summary>
        /// Creates a new instance of <see cref="PresentationParameters"/>.
        /// </summary>
        /// <param name="format">The back buffer format..</param>
        /// <param name="depthFormat">The depth-stencil buffer format.</param>
        /// <param name="width">The back buffer width.</param>
        /// <param name="height">The back buffer height.</param>
        /// <param name="isFullScreen">If the presentation should be full screen.</param>
        public PresentationParameters(SurfaceFormat format, DepthFormat depthFormat, int width, int height, bool isFullScreen) {
            BackBufferFormat = format;
            DepthStencilFormat = depthFormat;
            BackBufferWidth = width;
            BackBufferHeight = height;
            MultiSampleCount = 0;
            MultiSampleQuality = 0;
            IsFullScreen = isFullScreen;
            PresentInterval = PresentInterval.One;
            RenderTargetUsage = RenderTargetUsage.PlatformDefault;
            DisplayOrientation = DisplayOrientation.Default;
        }
    }
}
